




/*
'===============================================================================
'  MP.LayerHelper.MP_OBS.BL.MaSystemConstantManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.FactoryClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MP.LayerHelper.MP_OBS.BLL
{
	public class MaSystemConstantManagerBase : ManagerBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		
		public MaSystemConstantManagerBase()
		{
			// Nothing for now.
		}
		
		public override string TableName()
        {
            return "MaSystemConstant";
        }
		
		public MaSystemConstantEntity Insert(MaSystemConstantEntity _MaSystemConstantEntity)
		{
			return Insert(_MaSystemConstantEntity, "");
		}
		
		public MaSystemConstantEntity Insert(MaSystemConstantEntity _MaSystemConstantEntity, string controlId)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(_MaSystemConstantEntity, true);
				MaSystemConstantFields field = new MaSystemConstantFields();
                LogEntity(_MaSystemConstantEntity, field, AcInsert, controlId);
			}
			return _MaSystemConstantEntity;
		}

		
		public MaSystemConstantEntity Insert(string ConstantName, string ConstantValue, long IsEnabled, DateTime CreatedDate, byte[] CreatedBy, DateTime UpdatedDate, string UpdatedBy, long IsDeleted)
		{
			MaSystemConstantEntity _MaSystemConstantEntity = new MaSystemConstantEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MaSystemConstantEntity.ConstantName = ConstantName;
				_MaSystemConstantEntity.ConstantValue = ConstantValue;
				_MaSystemConstantEntity.IsEnabled = IsEnabled;
				_MaSystemConstantEntity.CreatedDate = CreatedDate;
				_MaSystemConstantEntity.CreatedBy = CreatedBy;
				_MaSystemConstantEntity.UpdatedDate = UpdatedDate;
				_MaSystemConstantEntity.UpdatedBy = UpdatedBy;
				_MaSystemConstantEntity.IsDeleted = IsDeleted;
				MaSystemConstantFields field = new MaSystemConstantFields();
                LogEntity(_MaSystemConstantEntity, field, AcInsert);
				adapter.SaveEntity(_MaSystemConstantEntity, true);
			}
			return _MaSystemConstantEntity;
		}

		public MaSystemConstantEntity Insert(string ConstantValue, long IsEnabled, DateTime CreatedDate, byte[] CreatedBy, DateTime UpdatedDate, string UpdatedBy, long IsDeleted)
		{
			MaSystemConstantEntity _MaSystemConstantEntity = new MaSystemConstantEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MaSystemConstantEntity.ConstantValue = ConstantValue;
				_MaSystemConstantEntity.IsEnabled = IsEnabled;
				_MaSystemConstantEntity.CreatedDate = CreatedDate;
				_MaSystemConstantEntity.CreatedBy = CreatedBy;
				_MaSystemConstantEntity.UpdatedDate = UpdatedDate;
				_MaSystemConstantEntity.UpdatedBy = UpdatedBy;
				_MaSystemConstantEntity.IsDeleted = IsDeleted;
				adapter.SaveEntity(_MaSystemConstantEntity, true);
				MaSystemConstantFields field = new MaSystemConstantFields();
                LogEntity(_MaSystemConstantEntity, field, AcInsert);
			}
			return _MaSystemConstantEntity;
		}
		
		public bool Update(MaSystemConstantEntity _MaSystemConstantEntity)
        {
            return Update(_MaSystemConstantEntity, "");
        }

		public bool Update(MaSystemConstantEntity _MaSystemConstantEntity, string controlId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(MaSystemConstantFields.ConstantName == _MaSystemConstantEntity.ConstantName);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_MaSystemConstantEntity, filter);
				toReturn = true;
				
				MaSystemConstantFields field = new MaSystemConstantFields();
                LogEntity(_MaSystemConstantEntity, field, AcUpdate, controlId);
			}
			return toReturn;
		}
		
		public bool Update(MaSystemConstantEntity _MaSystemConstantEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_MaSystemConstantEntity, filter);
				toReturn = true;
				
				MaSystemConstantFields field = new MaSystemConstantFields();
                LogEntity(_MaSystemConstantEntity, field, AcUpdate);
			}
			return toReturn;
		}

		public bool Update(string ConstantName, string ConstantValue, long IsEnabled, DateTime CreatedDate, byte[] CreatedBy, DateTime UpdatedDate, string UpdatedBy, long IsDeleted)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaSystemConstantEntity _MaSystemConstantEntity = new MaSystemConstantEntity(ConstantName);
				if (adapter.FetchEntity(_MaSystemConstantEntity))
				{
				
					_MaSystemConstantEntity.ConstantValue = ConstantValue;
					_MaSystemConstantEntity.IsEnabled = IsEnabled;
					_MaSystemConstantEntity.CreatedDate = CreatedDate;
					_MaSystemConstantEntity.CreatedBy = CreatedBy;
					_MaSystemConstantEntity.UpdatedDate = UpdatedDate;
					_MaSystemConstantEntity.UpdatedBy = UpdatedBy;
					_MaSystemConstantEntity.IsDeleted = IsDeleted;
					adapter.SaveEntity(_MaSystemConstantEntity, true);
					toReturn = true;
					
					MaSystemConstantFields field = new MaSystemConstantFields();
					LogEntity(_MaSystemConstantEntity, field, AcUpdate);
				}
			}
			return toReturn;
		}

		public bool Delete(string ConstantName)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaSystemConstantEntity _MaSystemConstantEntity = new MaSystemConstantEntity(ConstantName);
				if (adapter.FetchEntity(_MaSystemConstantEntity))
				{
					adapter.DeleteEntity(_MaSystemConstantEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", null);
			}
		}
		
		
		public int DeleteByConstantName(string ConstantName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantName == ConstantName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByConstantValue(string ConstantValue)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantValue == ConstantValue);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsEnabled(long IsEnabled)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByCreatedDate(DateTime CreatedDate)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByCreatedBy(byte[] CreatedBy)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByUpdatedDate(DateTime UpdatedDate)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByUpdatedBy(string UpdatedBy)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsDeleted(long IsDeleted)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemConstantEntity", filter);
			}
			return toReturn;
		}
		

		
		public MaSystemConstantEntity SelectOne(string ConstantName)
		{
			MaSystemConstantEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaSystemConstantEntity _MaSystemConstantEntity = new MaSystemConstantEntity(ConstantName);
				if (adapter.FetchEntity(_MaSystemConstantEntity))
				{
					toReturn = _MaSystemConstantEntity;
				}
			}
			return toReturn;
		}

		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectAllLST()
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, null, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectAllLST_Paged(int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, null, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}


		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByConstantNameLST(string ConstantName)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantName == ConstantName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByConstantNameLST_Paged(string ConstantName, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantName == ConstantName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return DataTable
		public DataTable SelectByConstantNameRDT(string ConstantName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantName == ConstantName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByConstantNameRDT_Paged(string ConstantName, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantName == ConstantName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByConstantValueLST(string ConstantValue)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantValue == ConstantValue);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByConstantValueLST_Paged(string ConstantValue, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantValue == ConstantValue);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return DataTable
		public DataTable SelectByConstantValueRDT(string ConstantValue)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantValue == ConstantValue);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByConstantValueRDT_Paged(string ConstantValue, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.ConstantValue == ConstantValue);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByIsEnabledLST(long IsEnabled)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByIsEnabledLST_Paged(long IsEnabled, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnabledRDT(long IsEnabled)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnabledRDT_Paged(long IsEnabled, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByCreatedDateLST(DateTime CreatedDate)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByCreatedDateLST_Paged(DateTime CreatedDate, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedDateRDT(DateTime CreatedDate)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedDateRDT_Paged(DateTime CreatedDate, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByCreatedByLST(byte[] CreatedBy)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByCreatedByLST_Paged(byte[] CreatedBy, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedByRDT(byte[] CreatedBy)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedByRDT_Paged(byte[] CreatedBy, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByUpdatedDateLST(DateTime UpdatedDate)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByUpdatedDateLST_Paged(DateTime UpdatedDate, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return DataTable
		public DataTable SelectByUpdatedDateRDT(DateTime UpdatedDate)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByUpdatedDateRDT_Paged(DateTime UpdatedDate, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByUpdatedByLST(string UpdatedBy)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByUpdatedByLST_Paged(string UpdatedBy, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return DataTable
		public DataTable SelectByUpdatedByRDT(string UpdatedBy)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByUpdatedByRDT_Paged(string UpdatedBy, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByIsDeletedLST(long IsDeleted)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return EntityCollection<MaSystemConstantEntity>
		public EntityCollection<MaSystemConstantEntity> SelectByIsDeletedLST_Paged(long IsDeleted, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemConstantEntity> _MaSystemConstantCollection = new EntityCollection<MaSystemConstantEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemConstantCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemConstantCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsDeletedRDT(long IsDeleted)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsDeletedRDT_Paged(long IsDeleted, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemConstantCollection = new EntityCollection(new MaSystemConstantEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemConstantFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemConstantCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		

	}
}
